<div class="modal-body">
	<form id="user-form" name="user-form" class="form-horizontal">
		<input type="hidden" name="id" id="zhtId">
		<input type="hidden" name="createTime" data-flag="date" data-format="yyyy-MM-dd HH:mm:ss">
		<input type="hidden" name="deleted">
		<div class="box-body">
			<div class="col-md-6">
				<div class="form-group">
					<label for="project_id" class="col-sm-3 control-label">所属项目</label>
					<div class="col-sm-8">
						<select id="project_id" class="form-control" name="project_id">
								<option value="" label="请选择所属项目"/>
						</select>
					</div>
				</div>
				<div class="form-group">
					<label for="location_lng" class="col-sm-3 control-label">地域经度</label>
					<div class="col-sm-8">
						<input type="text" class="form-control" id="location_lng" name="location_lng" placeholder="地域经度">
					</div>
				</div>
				
			</div>
			<div class="col-md-6">
				<div class="form-group">
					<label for="name" class="col-sm-3 control-label">灾害点名称</label>
					<div class="col-sm-8">
						<input type="text" class="form-control" id="name" name="name" placeholder="灾害点名称">
					</div>
				</div>
				<div class="form-group">
					<label for="location_lat" class="col-sm-3 control-label">地域纬度</label>
					<div class="col-sm-8">
						<input type="text" class="form-control" id="location_lat" name="location_lat" placeholder="地域纬度">
					</div>
				</div>
			</div>			
		</div>
		<!-- /.box-body -->
		<div class="box-footer text-right">
			<!--以下两种方式提交验证,根据所需选择-->
			<button type="button" class="btn btn-default" data-btn-type="cancel" onclick="dialog_close()">取消</button>
			<button type="button" class="btn btn-primary" data-btn-type="save" onclick="save_zht()">提交</button>
		</div>
		<!-- /.box-footer -->
	</form>
</div>
<script type="text/javascript">
	$(document).ready(function(){
		initProject("project_id");
	});
	
	function initProject( sel_id, fn ){
		var url = "../../tbl_project/list";
		var paramMap = {};
		paramMap.city_code = global.system_city_code;
		paramMap.page = 1;
		paramMap.pagesize = 999;
		var json_data = JSON.stringify( paramMap );
		$.ajax({
			  url: url,
			  type : 'post',
			  async : false,
			  data: json_data,
			  contentType: "application/json; charset=utf-8",
			  dataType: "json",
			  success: function( json ) {
				  $(json.data).each(function(){
						$( "#" + sel_id ).append("<option value='"+ this.id +"'>"+ this.name +"</option>");
				  });
				  if( fn ){
					  fn();
				  }
			  }
		});
	}
	
	function save_zht( fn ){
		var location_lng = null;
		var zht = {};
		zht.name = $("#name").val();
		zht.project_id = $("#project_id").val();
		if( $("#location_lng").val() ){
			location_lng = parseFloat($("#location_lng").val());
		}
		if( $("#location_lat").val() ){
			location_lat = parseFloat($("#location_lat").val());
		}
		zht.location_lng = location_lng;
		zht.location_lat = location_lat;
		var json_data = JSON.stringify( zht );
		var url = "../../tbl_zht/save";
		$.ajax({
			  url: url,
			  type : 'post',
			  async : false,
			  data: json_data,
			  contentType: "application/json; charset=utf-8",
			  dataType: "json",
			  success: function(json) {
				 global.alert( json.message );
				 $("#zht_main").load("zht_list.html");
				 dialog_close();
			  }
		});
	}
	
	function dialog_close(){
		global.dialog.close()
	}
</script>